﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VietThinks.Contract;
using VietThinks.Model;

namespace VietThinks.Service
{
    public class ProductService
    {
        public IList<ProductDto> GetProduct()
        {
            using (var repository = DomainRepository.Open())
            {
                var categories = repository.Query<Product>().ToList();

                return categories.Select(c => Convert.Entity(c).ToDto<ProductDto>()).ToList();
            }
        }
        public void AddOrUpdate(ProductDto dto)
        {
            using (var repository = DtoRepository<ProductDto, Product>.Open())
            {
                repository.AddOrUpdate(dto);
            }
        }
    }
}
